/*
 * Group 3, User Interface Programming II (vt11)
 * Pooya | Flora | Monica | Can
 */
package vical.action;

import java.awt.event.ActionEvent;
import java.util.Locale;
import javax.swing.AbstractAction;
import javax.swing.JOptionPane;
import vical.controller.PreferenceController;
import vical.model.Internationalization;
import vical.view.MainWindow;

/**
 * Triggers changing the interface language.
 *
 * @author WoKe
 * @author Can
 */
public class ToSwedishAction extends AbstractAction {

    private MainWindow mainWindow;

    public ToSwedishAction(MainWindow mainWindow) {
        super(Internationalization.getString("SwedishLanguage"));
        putValue(MNEMONIC_KEY, Internationalization.getMnemonic("mnemonics_language_svenska"));
        this.mainWindow = mainWindow;
    }

    public void actionPerformed(ActionEvent e) {
        PreferenceController.setLocale(new Locale("sv"));
        if (Internationalization.loadLanguage(PreferenceController.getLocale()) != 0) {
            return;
        }
        mainWindow.saveParameters();
        mainWindow.dispose();
        mainWindow = new MainWindow();
        mainWindow.setVisible(true);

        //JOptionPane.showMessageDialog(null, Internationalization.getString("langChange"));
    }
}
